﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;

namespace COC.Threading
{
    public class WorkEventItem : Object, IComparable
    {
        public int type;
        public event EventCallback BeforeCallback; //execute this method before handle EventHandler
        public event EventCallback AfterCallback;//execute this method after handle EventHandler is completed
        public event EventCallback EventHandler;//thread which to execute. 
        public bool isComplete = false;
        public delegate Object EventCallback();
        public bool isError = false;
        public Object arg;
        public void ExecuteBeforeCallback()
        {
            UnityEngine.Debug.Log("--------------ExecuteBeforeCallback-------------------------------");
            if (BeforeCallback != null)
                BeforeCallback();
        }
        public void ExecuteAfterCallback()
        {
            UnityEngine.Debug.Log("--------------ExecuteAfterCallback-------------------------------");

            if (AfterCallback != null) AfterCallback();
        }
        public void RemoveAllCallback()
        {
            UnityEngine.Debug.Log("--------------ExecuteRemoveAllCallback-------------------------------");
            if (BeforeCallback != null)
                BeforeCallback = null;
            if (AfterCallback != null)
                AfterCallback = null;
        }
        public int CompareTo(object obj)
        {
            WorkEventItem target = (WorkEventItem)obj;
            if (target.type > this.type)
            {
                return -1;
            }
            if (target.type < this.type)
            {
                return 1;
            }
            return 0;
        }
    }
}
